/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.rooster.test;

import org.rooster.manager.ResourceManager;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;

public class MinMaxLabelRenderer extends DefaultTableCellRenderer {

    @Override
    public Component getTableCellRendererComponent(JTable table,
                                                   Object value, boolean isSelected, boolean hasFocus, int row,
                                                   int column) {

        JLabel label = new JLabel(value.toString());
        if(column==1) {
            int val=Integer.parseInt(value.toString());
            if (true) {
                if (val< ResourceManager.MIN_WORKING_SLOTS) {
                    label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/yellow.png")));
                }
                else if(val> ResourceManager.MAX_WORKING_SLOTS) {
                    label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/red.png")));
                }
                else {
                    label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/green.png")));
                }
                return label;
            } else {
                return null;
            }
        }
        else {
            return  label;
        }
    }
}
